package Practice03;

public class Vehicle {
    //车辆内部数据采用牛顿，外部采用千克
    private double load;
    private double maxLoad;
    public Vehicle(double maxLoad){
        this.maxLoad = kiloToNewts(maxLoad);//千克转牛顿存入
    }

    public Boolean addBox(double weight){
        load += kiloToNewts(weight);
        if (load > maxLoad){
            load -= kiloToNewts(weight);
            return false;
        }
        return true;
    }

    private double kiloToNewts(double weight) {
        return (weight * 9.8);
    }

    private double newtsToKilo(double weight) {
        return (weight / 9.8);
    }
    public double getLoad() {
        return newtsToKilo(load);
    }

    public double getMaxLoad() {
        return newtsToKilo(maxLoad);
    }
}
